# 导入模块
from openpyxl import Workbook
# # 创建workbook
# wb = Workbook()
# # 激活worksheet
# ws = wb.active
# # A1 单元格赋值42
# ws['A1'] = 42
#
# # A1 下面一行追加元素
# ws.append([1, 2, 3])
#
# # A2 单元格设置值为当前时间
# import datetime
# ws['A2'] = datetime.datetime.now()
#
# # 保存到文件
# wb.save("sample.xlsx")

# 导入加载数据文件模块
from openpyxl import load_workbook

# 加载Excel文件
wb = load_workbook(filename='data/data.xlsx')
# 打印workbook中所有的sheet
# print(wb.worksheets)

# 加载worksheet
ws = wb['topics']
# print(ws['B'].value)
test_data = []

print(len(tuple(ws.columns)))

for x in range(2, len(tuple(ws.rows))+1):
    testcase_data = []
    for y in range(2, 7):
        testcase_data.append(ws.cell(row=x, column=y).value)
        print(ws.cell(row=x, column=y).value, type(ws.cell(row=x, column=y).value))
    test_data.append(testcase_data)

print(test_data)

test_data = [
    ['http://49.233.108.117:3000/api/v1/topics', 'post', '{"accesstoken":"1","title":"","tab":"","content":""}', 401,'{"success":false,"error_msg":"错误的accessToken"}'],
    ['http://49.233.108.117:3000/api/v1/topics', 'post','{"accesstoken":"e983ec8e-fc0b-4be2-845c-508452c4ad9a","title":"11111111111111","tab":"","content":""}',400, '{"success":false,"error_msg":"必须选择一个版块"} ']
]
